from bpmappers import RawField, DelegateField
from bpmappers.djangomodel import ModelMapper

from carsearch.models import Record, Car


class CarMapper(ModelMapper):

    class Meta:
        model = Car
        fields = ('carno', 'owner')


class RecordMapper(ModelMapper):
    car = DelegateField(CarMapper)
    time = RawField('offend_time')
    place = RawField('offend_place')
    reason = RawField('offend_reason')

    class Meta:
        model = Record
        exclude = ('offend_time', 'offend_place', 'offend_reason')
